package cn.edu.xmu.experiment.PulseComms.controller;


import cn.edu.xmu.experiment.PulseComms.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/{username}/login")
    public void login(@PathVariable String username) {
        userService.login(username);
    }

    @PostMapping("/{username}/logout")
    public void logout(@PathVariable String username) {
        userService.logout(username);
    }

    @GetMapping("/{username}/status")
    public boolean getStatus(@PathVariable String username) {
        return userService.isLoggedIn(username);
    }

}    